import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

import '../../services/screen_adapter.dart';

class ProductContentSecond extends StatefulWidget {

  final List _productContentList;

  ProductContentSecond(this._productContentList, {Key key}) : super(key: key);

  @override
  _ProductContentFirstState createState() => _ProductContentFirstState();
}

/// mixin继承with AutomaticKeepAliveClientMixin，实现缓存
class _ProductContentFirstState extends State<ProductContentSecond> with AutomaticKeepAliveClientMixin{

  var _id;

  /// 需要实现此方法
  @override
  bool get wantKeepAlive => true;

  @override
  void initState() {
    super.initState();
    _id = widget._productContentList[0].sId;
  }

  @override
  Widget build(BuildContext context) {
    ScreenAdapter.init();
    return Container(
      padding: EdgeInsets.only(bottom: ScreenAdapter.height(88)),
      child: Column(
        children: <Widget>[
          Expanded(
            child: InAppWebView(
              initialUrl: "http://jd.itying.com/pcontent?id=$_id",
              onProgressChanged: (InAppWebViewController controller, int progress) {
                
              }
            )  
          )
        ],
      )
    );
  }
}